import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;


public class MySQLTest {
	
	public static void main(String[] args){
		try
		{
			new MySQLTest().top();
		}
		catch(Exception e){
			System.out.println("Fehler: " + e);
			e.printStackTrace();
		}
		finally{
			System.out.println("APPLICATION TERMINATED");
		}
	}
	
	String connURL = "jdbc:mysql://localhost/testtable";
	
	void top() throws SQLException{
		Connection con;
		Statement  stmt;
		ResultSet  rs;
		
		con = DriverManager.getConnection(connURL,"POTuser", "POTpass");
		//System.out.println(con);
		
		stmt = con.createStatement();
		rs = stmt.executeQuery("SELECT * FROM ort");
		//System.out.println(rs);
		while(rs.next()){
			int plz = rs.getInt("PLZ");
			String ort = rs.getString("Ortname");
			System.out.println(plz + " " + ort);
		}
		
		stmt.close();
		con.close();
	}
}
